<?php
class Loader {
	
	/**
	 * Array contains className => classPath
	 *
	 * @var array
	 */
	private static $classMap = array();
	
	/**
	 * Register class map
	 *
	 * @param array $hash
	 */
	static function register($hash) {
		self::$classMap = array_merge(self::$classMap, $hash);
	}
	
	/**
	 * Load class
	 *
	 * @param string $className
	 */
	static function load($className) {
		if (!isset(self::$classMap[$className]))
			throw new Exception('class '.$className.' not registered');
		$filename = Config::$path. self::$classMap[$className];
		if (!file_exists($filename))
			throw new Exception('class '.$className.' not found at '.$filename);
		require_once($filename);
	}
}